clear,clc

ListPath = '/mri_projects/ASD_Analysis/Lists';
GU_DIR = '/mri_projects/ASD_Analysis/Scripts/fc_mats/GU';
GU_ASD_SIDs = textread([ListPath '/variability_list_HC_GU.txt'],'%s');

for s = 1:length(GU_ASD_SIDs)
    fprintf(['[step]: ' num2str(s) ' start \n']);
    sid = GU_ASD_SIDs{s}

    item_data = load([GU_DIR '/' sid '_fc.mat'])
    fc_data = item_data.fc
    [vol, M, mr_parms, volsz] = load_mgh('/mri_projects/ASD_Analysis/Parcellation_template/lh_network_19_asym_fs4.mgh');
    temp_indices = find(vol==1);

    roi_rows = fc_data(:, temp_indices);
    roi_val = mean(roi_rows, 2)

    lh_data = roi_val(1:2562, :);
    rh_data = roi_val(2563:5124, :);

    save_mgh(lh_data, ['./fc_results/lh_fs4_' sid '.mgh'], eye(4));
    save_mgh(rh_data, ['./fc_results/rh_fs4_' sid '.mgh'], eye(4));
end